﻿using ManagementApi.Models;
using ManagementApi.Models.Manager;
using ManagementApi.Models.Project;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Modules.Manager;

namespace ManagementApi.Controllers.CorpPannel
{
    /// <summary>
    /// 项目管理员接口
    /// </summary>
    [Route("/api/v1/corp/manager")]
    [ApiController]
    [Authorize(Roles = "Corp")]
    public class ManagerController : ControllerBase
    {
        private readonly ManagerService managerService;

        public ManagerController(ManagerService managerService)
        {
            this.managerService = managerService;
        }

        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="query"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet("page")]
        public ApiResult<PageDto<ManagerDto>> GetManagers([FromQuery] ManagerQuery query, int pageIndex = 1, int pageSize = 20)
        {
            var pageDto = managerService.GetManagers(query, pageIndex, pageSize).AsPageDto(m => m.AsDto());
            return ApiResult<PageDto<ManagerDto>>.Success(pageDto);
        }
    }
}